package com.tehmur.android.menuTest;

import android.app.Activity;
import android.os.Bundle;
//import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
//import android.widget.AdapterView.OnItemLongClickListener;

public class Duas extends Activity {
    
	private ListView lv;
	//get the end of line character as it is OS dependent - not
	//necessarily \n
	String eol = System.getProperty("line.separator"); 
	
	//Strings of duas
	String d1 = "Narrated by Abu Huraira Allah's Apostle said, " +
	"\"Whoever says, 'La ilaha illal-lah wahdahu la sharika lahu, " +
	"lahu-l-mulk wa lahu-l-hamd wa huwa 'ala kulli shai'in qadir', " +
	"one hundred times will get the same reward as given for manumitting" +
	" ten slaves and one hundred good deeds will be written in his " +
	"accounts, and one hundred sins will be deducted from his accounts," +
	" and it (his saying) will be a shield for him from Satan on that day" +
	" till night, and nobody will be able to do a better deed except the" +
	" one who does more than he.\" " + eol + 
	"Sahih Al Bukhari, Volume 8, Book 75(Book of Invocations), Number 412 " + eol;
	
	String d2 = "Narrated by Abu Huraira Allah's Apostle said, \"Whoever says," +
			"'Subhan Allah wa bihamdihi', one hundred times a day, will be " +
			"forgiven all his sins even if they were as much as the foam " +
			"of the sea.\"" + eol +
	"Sahih Al Bukhari, Volume 8, Book 75(Book of Invocations), Number 414" + eol;
	
	//array of duas
	private String arr[] = {d1, d2};
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.duas);  
        lv = (ListView)findViewById(R.id.ListView01);
        lv.setAdapter(new ArrayAdapter<String>(this, 
        		android.R.layout.simple_list_item_1, arr));

        //performs action when item in list view is clicked on
        lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { 
        	public boolean onItemLongClick(AdapterView<?> av, View v, 
        			int pos, long id) { 
        	return onLongListItemClick(v,pos,id); 
        	} 
        }); 

    }
    
    //action performed when item is clicked on - here(for now)shows text as toast
    protected boolean onLongListItemClick(View v, int pos, long id) { 
    	//Log.i("onLongListItemClick id=" + id);
    	Toast.makeText(getApplicationContext(), ((TextView) v).getText(),
    	          Toast.LENGTH_SHORT).show();

    	return true; 
    	} 

}